﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Silvermoon.OpenGL.Native.Vectors;
using System.Drawing;

namespace Silvermoon.OpenGL.Native
{

    [StructLayout(LayoutKind.Sequential)]
    public struct VectorQuads
    {
        public Vector2s BottomLeft;
        public Vector2s TopLeft;
        public Vector2s BottomRight;
        public Vector2s TopRight;

        public void SetChar(int left, int top, int width, int height, int skew)
        {
            int right = left + width;
            int bottom = top + height;

            TopLeft.Set(left + skew, top);
            TopRight.Set(right + skew, top);
            BottomLeft.Set(left - skew, bottom);
            BottomRight.Set(right - skew, bottom);
        }

        internal Rectangle GetRect()
        {
            int x = TopLeft.X;
            int y = TopLeft.Y;
            int r = BottomRight.X;
            int b = BottomRight.Y;
            return new Rectangle(x, y, r - x, b - y);
        }

        internal void AdWidth(int delta)
        {
            TopRight.X += (short)delta;
            BottomRight.X += (short)delta;
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct VectorQuad2f
    {
        public Vector2f BottomLeft;
        public Vector2f TopLeft;
        public Vector2f BottomRight;
        public Vector2f TopRight;

        public void Set(float left, float top, float right, float bottom)
        {
            TopLeft.Set(left, top);
            TopRight.Set(right, top);
            BottomLeft.Set(left, bottom);
            BottomRight.Set(right, bottom);
        }

    }

    [StructLayout(LayoutKind.Sequential)]
    public struct VectorQuad2i
    {
        public Vector2i BottomLeft;
        public Vector2i TopLeft;
        public Vector2i BottomRight;
        public Vector2i TopRight;

        public void Set(int left, int top, int right, int bottom)
        {
            TopLeft.Set(left, top);
            TopRight.Set(right, top);
            BottomLeft.Set(left, bottom);
            BottomRight.Set(right, bottom);
        }

    }

}
